//
//  BusinessGatheringDetailViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/12/10.
//  Copyright © 2015年 reabam.com. All rights reserved.
//

#import "BusinessGatheringDetailViewController.h"
#import "RDVTabBarController.h"
#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "addhuiyuanViewController.h"
#import "GatheringListCell.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "UIButton+WebCache.h"
@interface BusinessGatheringDetailViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate>


@end

@implementation BusinessGatheringDetailViewController

{
    HAODEsingleton* commdity;
    UISearchBar *search;
    UIScrollView*MYmainScroll;
    
}


-(void)BackAction:(UIButton *)sender{
    
    
   [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    
    self.title=@"交易详情";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    commdity=[HAODEsingleton shared];

    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:commdity. gid forKey:@"gid"];
    
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    NSLog(@"-----------%@", param);
    
    [HttpRequest requestData:@"Business/Gathering/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                
                MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,64, ScreenWidth, ScreenHeight)];
                MYmainScroll.delegate = self;
                MYmainScroll.userInteractionEnabled = YES;
                MYmainScroll.scrollEnabled = YES;
                MYmainScroll.showsVerticalScrollIndicator = FALSE;
                MYmainScroll.showsHorizontalScrollIndicator = FALSE;
                [self.view addSubview:MYmainScroll];
               
                UILabel*status=[[UILabel alloc]initWithFrame:CGRectMake(20, 0, ScreenWidth, 80)];
                status.textAlignment=NSTextAlignmentCenter;
                status.font= [UIFont systemFontOfSize:18];
                [status setTextColor:backColor];
                [MYmainScroll addSubview:status];
           
        if ([[severDataDict.dataDict objectForKey:@"status"]isEqualToString:@"Y"]) {
                    status.text=@"交易成功!";
                    UIImageView *gou = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2-50,50/2, 30, 30)];
                    gou.image=[UIImage imageNamed:@"gous"];
                    [MYmainScroll addSubview:gou];
               
            }else{
                
                 status.text=@"交易失败!";
                    UIImageView *gou = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2-50,50/2, 30, 30)];
                    gou.image=[UIImage imageNamed:@"jiaoyishibai"];
                    [MYmainScroll addSubview:gou];
                }
         
                
                UILabel*jianyijine=[[UILabel alloc]initWithFrame:CGRectMake(20, 95, 120, 30)];
                jianyijine.text=@"交易金额";
                jianyijine.font= [UIFont systemFontOfSize:15];
                [jianyijine setTextColor:shenhuicolor];
                [MYmainScroll addSubview:jianyijine];
                
                
                UILabel*jianyijine1=[[UILabel alloc]initWithFrame:CGRectMake(0, 170/2, ScreenWidth, 150)];
                jianyijine1.textAlignment=NSTextAlignmentCenter;
                jianyijine1.font= [UIFont systemFontOfSize:40];
                [jianyijine1 setTextColor:backColor];
                NSString*GoldPrice=[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"payAmount"]];
                NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
                [numberFormatter setPositiveFormat:@"###,##0.00;"];
                NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
                jianyijine1.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString];
                
                NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥ %@" ,formattedNumberString]];
                
                [AttributedStr addAttribute:NSFontAttributeName
                 
                                      value:[UIFont systemFontOfSize:20.0]
                 
                                      range:NSMakeRange(0, 1)];
                
                [AttributedStr addAttribute:NSForegroundColorAttributeName
                 
                                      value:backColor
                                      range:NSMakeRange(0, 1)];
                jianyijine1.attributedText = AttributedStr;
                [MYmainScroll addSubview:jianyijine1];
                
                
                
                
                UILabel *lines=[[UILabel alloc] initWithFrame:CGRectMake(15, 410, ScreenWidth-30, 0.35)];
                lines.backgroundColor=qianhuicolor;
                [MYmainScroll addSubview:lines];
                UILabel *lines1=[[UILabel alloc] initWithFrame:CGRectMake(15, 240-0.35, ScreenWidth-30, 0.35)];
                lines1.backgroundColor=qianhuicolor;
                [MYmainScroll addSubview:lines1];
                UIImageView *_xianview1 = [[UIImageView alloc]initWithFrame:CGRectMake(15,80, ScreenWidth-30, 0.5)];
                _xianview1.image=[UIImage imageNamed:@"hengxian"];
                [MYmainScroll addSubview:_xianview1];

                
                UILabel*jiaoyimingcheng=[[UILabel alloc]initWithFrame:CGRectMake(20, 250, 120, 30)];
                jiaoyimingcheng.text=@"交易名称";
                jiaoyimingcheng.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyimingcheng setTextColor:shenhuicolor];
                [MYmainScroll addSubview:jiaoyimingcheng];
                
                UILabel*jiaoyimingcheng1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 250, 180, 30)];
                
                if ([[severDataDict.dataDict objectForKey:@"payType"]isEqualToString:@"wx_pay_scan"]) {
                    jiaoyimingcheng1.text=[NSString stringWithFormat:@"%@",  @"微信扫码支付"];
                   
                }
                if ([[severDataDict.dataDict objectForKey:@"payType"]isEqualToString:@"CashPay"]) {
                   jiaoyimingcheng1.text=[NSString stringWithFormat:@"%@",  @"现金支付"];
                    
                }
                if ([[severDataDict.dataDict objectForKey:@"payType"]isEqualToString:@"IboxPay"]) {
                    jiaoyimingcheng1.text=[NSString stringWithFormat:@"%@",  @"盒子支付"];
      
                }
                if ([[severDataDict.dataDict objectForKey:@"payType"]isEqualToString:@"AliQrPay"]) {
                    jiaoyimingcheng1.text=[NSString stringWithFormat:@"%@",  @"支付宝支付"];
                    
                }
           
                jiaoyimingcheng1.textAlignment=NSTextAlignmentRight;
                jiaoyimingcheng1.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyimingcheng1 setTextColor:backColor];
                [MYmainScroll addSubview:jiaoyimingcheng1];

                UILabel*jiaoyileixing=[[UILabel alloc]initWithFrame:CGRectMake(20, 280, 120, 30)];
                jiaoyileixing.text=@"交易类型";
                jiaoyileixing.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyileixing setTextColor:shenhuicolor];
                [MYmainScroll addSubview:jiaoyileixing];

                UILabel*jiaoyileixing1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 280, 180, 30)];
                if ([[severDataDict.dataDict objectForKey:@"orderType"]isEqualToString:@"order"]) {
                   jiaoyileixing1.text =[NSString stringWithFormat:@"%@",@"订单"];
                   
                    
                    
                }
                if ([[severDataDict.dataDict objectForKey:@"orderType"]isEqualToString:@"service"]) {
                   jiaoyileixing1.text =[NSString stringWithFormat:@"%@",@"服务"];
                  
                    
                }
                
                if ([[severDataDict.dataDict objectForKey:@"orderType"]isEqualToString:@"other"]) {
                   jiaoyileixing1.text =[NSString stringWithFormat:@"%@",@"自定义"];
                  
                    
                    
                }

//                jiaoyileixing1.text=[severDataDict.dataDict objectForKey:@"orderType"];
                 jiaoyileixing1.textAlignment=NSTextAlignmentRight;
                jiaoyileixing1.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyileixing1 setTextColor:backColor];
                [MYmainScroll addSubview:jiaoyileixing1];

                UILabel*jiaoyidanhao=[[UILabel alloc]initWithFrame:CGRectMake(20, 310, 120, 30)];
                jiaoyidanhao.text=@"交易单号";
                jiaoyidanhao.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyidanhao setTextColor:shenhuicolor];
                [MYmainScroll addSubview:jiaoyidanhao];
                UILabel*jiaoyidanhao1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-260, 310, 240, 30)];
                jiaoyidanhao1.text=[severDataDict.dataDict objectForKey:@"orderNo"];
                 jiaoyidanhao1.textAlignment=NSTextAlignmentRight;
                jiaoyidanhao1.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyidanhao1 setTextColor:backColor];
                [MYmainScroll addSubview:jiaoyidanhao1];

                UILabel*liushuihao=[[UILabel alloc]initWithFrame:CGRectMake(20, 340, 120, 30)];
                liushuihao.text=@"流水号";
                liushuihao.font= [UIFont systemFontOfSize:contenfot];
                [liushuihao setTextColor:shenhuicolor];
                [MYmainScroll addSubview:liushuihao];

                UILabel*liushuihao1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-260, 340, 240, 30)];
                liushuihao1.text=[severDataDict.dataDict objectForKey:@"tradeNo"];
                liushuihao1.textAlignment=NSTextAlignmentRight;
                liushuihao1.font= [UIFont systemFontOfSize:contenfot];
                [liushuihao1 setTextColor:backColor];
                [MYmainScroll addSubview:liushuihao1];

                UILabel*jiaoyishijian=[[UILabel alloc]initWithFrame:CGRectMake(20, 370, 120, 30)];
                jiaoyishijian.text=@"交易时间";
                jiaoyishijian.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyishijian setTextColor:shenhuicolor];
                [MYmainScroll addSubview:jiaoyishijian];

                UILabel*jiaoyishijian1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 370, 180, 30)];
                jiaoyishijian1.text=[severDataDict.dataDict objectForKey:@"createDate"];
                jiaoyishijian1.textAlignment=NSTextAlignmentRight;
                jiaoyishijian1.font= [UIFont systemFontOfSize:contenfot];
                [jiaoyishijian1 setTextColor:backColor];
                [MYmainScroll addSubview:jiaoyishijian1];



                
                
                
                commdity.Memo=[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"remark"]];
                
                UILabel*beizhu=[[UILabel alloc]initWithFrame:CGRectMake(20, 420, ScreenWidth*70/750, 45)];
                beizhu.text=@"备注";
                beizhu.font= [UIFont systemFontOfSize:contenfot];
                [beizhu setTextColor:qianheicolor];
                [MYmainScroll addSubview:beizhu];
                
                NSString *s1 =[NSString stringWithFormat:@"%@", commdity.Memo];
                UIFont *font1 = [UIFont systemFontOfSize:contenfot];
                CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                
                UILabel*beizhu1=[[UILabel alloc]initWithFrame:CGRectMake(20, beizhu.bottom+2, ScreenWidth-40, labelsize1.height+30)];
                beizhu1.text=s1;
                beizhu1.numberOfLines=0;
                beizhu1.font= [UIFont systemFontOfSize:contenfot];
                [beizhu1 setTextColor:shenhuicolor];
                [MYmainScroll addSubview:beizhu1];
            
                [MYmainScroll setContentSize:CGSizeMake(ScreenWidth, ScreenHeight)];
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];

    
    
    
    
    
    
    
    
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
